package com.fyl.security;


import com.fyl.security.aop.OAuthAdvisor;
import com.fyl.security.aop.OAuthMethodInterceptor;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;

@Configuration
public class OAuthConfiguration {

    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @ConditionalOnMissingBean
    public OAuthMethodInterceptor oauthMethodInterceptor() {
        return new OAuthMethodInterceptor();
    }

    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @ConditionalOnMissingBean
    public OAuthAdvisor oauthAdvisor(OAuthMethodInterceptor oauthMethodInterceptor) {
        return new OAuthAdvisor(oauthMethodInterceptor);
    }
}
